"use strict";
const http = require('http');
const iconv = require('iconv-lite');
const cheerio = require('cheerio');
const Service = require('egg').Service;
function catchData () {
    return new Promise((resolve, reject) => {
        console.log(1)
        http.get('http://tianqi.2345.com/nanshan/72037.htm',function(req,res){
            console.log(2)
            let  html = ''
            req.on('data',function(chunk){
                html += iconv.decode(chunk, 'GBK')
            });
            req.on('end',function(){
                const $ = cheerio.load(html);
                resolve($('a.data').text())
                console.log(3)
            });
        });
    })
}

class Spider extends Service {
    async spiderData () {
        return await catchData();
    }
}
module.exports = Spider;
